﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="collaboration_pesonal_index.aspx.cs" Inherits="Ccit.Mgoa.Collaboration.collaboration_pesonal_index" %>

<%@ Register Assembly="DevExpress.Web.ASPxGridView.v8.1" Namespace="DevExpress.Web.ASPxGridView"
    TagPrefix="dxwgv" %>
<%@ Register TagPrefix="ccit" Namespace="Ccit.ServerControls" Assembly="Ccit.ServerControls.ActionForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>协作空间-我的协作</title>
    <script language="javascript" type="text/javascript" src="../script/jwindow.js"></script>
    <script language="javascript" type="text/javascript" src="../script/jquery.js"></script>
    <script language="javascript" type="text/javascript" src="../script/StringClass_Ext.js"></script>
    <script language="javascript" type="text/javascript" src="../script/jsonlib.js"></script>
    <script language="javascript" type="text/javascript" src="../script/jbase64.js"></script>
    <script language="javascript" type="text/javascript">
        function doEdit(oId)
        {
            var oParam="id="+oId;
            var oEncodeParam=base64encode(oParam);
            window.location.href="collaboration_pesonal_edit.aspx?"+oEncodeParam;
        }
        
        function doView(oId)
        {
            var oParam="id="+oId;
            var oEncodeParam=base64encode(oParam);
            OpenWindow("collaboration_pesonal_view.aspx?"+oEncodeParam,"",800,600);
        }
        
        function doOperate(oId,oStatus)
        {
            var oChangedStatus="0";
            var oOperate="";
            var oFinishDate="";
            var oKeepCommentInfo=true;
            if(oStatus=="0") //启动协作
            {
                oOperate="start";
                PageMethods.OperateCollaborativeTopic(oId,oFinishDate,oKeepCommentInfo,oOperate,ClientCallBack);
            }
            else if(oStatus=="1") //终止协作
            {
                oOperate="stop";
                if(confirm("确定要终止该协作吗？"))
                    PageMethods.OperateCollaborativeTopic(oId,oFinishDate,oKeepCommentInfo,oOperate,ClientCallBack);
            }
            else if(oStatus=="2") //重启协作
            {
                PageMethods.GetCollaborativeTopic(oId,ClientCallBack1);
            }
        }
        
        function ClientCallBack1(oResult)
        {
            var objResult=JSON.parse(oResult);
            var oId=objResult.Id;
            var oPublishDate =objResult.PublishDate;
            var oFinishDate =objResult.FinishDate;
            var oParamArr=new Array(oId,oPublishDate,oFinishDate);
            var oResult = window.showModalDialog("collaboration_pesonal_reset.aspx"+oEncodeParam,oParamArr,"dialogHeight:209px;dialogWidth:240px;help:no;edge:Raised;resizable:no;titlebar:no");
            if(oResult!=undefined&&oResult!=null)
            {
                oFinishDate=oResult[0];
                oKeepCommentInfo=oResult[1];
                PageMethods.OperateCollaborativeTopic(oId,oFinishDate,oKeepCommentInfo,"restart",ClientCallBack);
            }
        }
        
        /* 删除协作 */
        function doDelete()
        {
            var oIds=document.getElementById("hdId").value;
            if(oIds=="")
            {
                alert("请选择要删除的协作！");
                return;
            }
            if(confirm("确认要删除选择的协作？"))
                PageMethods.OperateCollaborativeTopic(oIds,"",false,"delete",ClientCallBack);
        }
        
        function ClientCallBack(oResult)
        {
            var objResult=JSON.parse(oResult);
            var oOperate=objResult.Operate;
            var oExtResult=objResult.Result;
            switch(oOperate)
            {
                case "delete":
                    if(oExtResult)
                    {
                        alert("删除成功！");
                        __doPostBack("lnkSearch","");
                    }
                    break;
                case "start":
                    if(oExtResult)
                    {
                        alert("启动协作成功！");
                        __doPostBack("lnkSearch","");
                    }
                    break;
                case "stop":
                    if(oExtResult)
                    {
                        alert("终止协作成功！");
                        __doPostBack("lnkSearch","");
                    }
                    break;
                case "restart":
                    if(oExtResult)
                    {
                        alert("重启协作成功！")
                        __doPostBack("lnkSearch","");
                    }
                    break;
                default :
                    break;
            }
        }
        
        /* 更改基本查询查询方式 */
        function doChangeType()
        {
            initBasic();
            disposeBasic();
        }
        
        function initBasic()
        {
            var oCollaborate = $get("selCollaborate").value;
            if(oCollaborate=="1")
            {
                $get("txtCollaborativeTitle1").style.display="block";
                $get("selCollaborativeType1").style.display="none";
                $get("txtPublisher1").style.display="none";
                $get("selCollaborativeStatus").style.display="none";
            }
            else if(oCollaborate=="2")
            {
                $get("txtCollaborativeTitle1").style.display="none";
                $get("selCollaborativeType1").style.display="block";
                $get("txtPublisher1").style.display="none";
                $get("selCollaborativeStatus").style.display="none";
            }
            else if(oCollaborate=="3")
            {
                $get("txtCollaborativeTitle1").style.display="none";
                $get("selCollaborativeType1").style.display="none";
                $get("txtPublisher1").style.display="block";
                $get("selCollaborativeStatus").style.display="none";
            }
            else if(oCollaborate=="4")
            {
                $get("txtCollaborativeTitle1").style.display="none";
                $get("selCollaborativeType1").style.display="none";
                $get("txtPublisher1").style.display="none";
                $get("selCollaborativeStatus").style.display="block";
            }
        }
        /* 初始化基本查询条件 */
        function disposeBasic()
        {
            $get("txtCollaborativeTitle1").value="";
            $get("selCollaborativeType1").value="";
            $get("txtPublisher1").value="";
            $get("selCollaborativeStatus").selectedIndex=0;
        }
        
        /* 初始化高级查询查询条件 */
        function disponseAdvanced()
        {
            $get("txtCollaborativeTitle").value="";
            $get("selCollaborativeType").value="";
            $get("txtPublisher").value="";
            $get("selStatus").selectedIndex=0;
            $get("txtBeginDate").value="";
            $get("txtEndDate").value="";
        }
        
        /* 高级查询 */
        function doAdvanceSearch()
        {
            document.getElementById("trBasic").style.display="none";
            document.getElementById("trAdvanced").style.display="block";
            $get("hdSearchType").value="advanced";
            $get("selCollaborate").selectedIndex=0;
            doChangeType();
        }
        
        /* 隐藏高级查询 */
        function doHiddeAdvance()
        {
            document.getElementById("trBasic").style.display="block";
            document.getElementById("trAdvanced").style.display="none";
            $get("hdSearchType").value="basic";
            disponseAdvanced();
        }
        
        /* 查询 */
        function doSearch()
        {
            __doPostBack("lnkSearch","");
        }
        
        /* 初始化页面 */
        $(document).ready(function(){
            var oSearchType=$get("hdSearchType").value;
            if(oSearchType=="basic")
            {
                doHiddeAdvance();
                initBasic();
            }
            else if(oSearchType=="advanced")
            {
                doAdvanceSearch();
            }
        });
    </script>
</head>
<body>
    <ccit:ActionForm id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server"></asp:ScriptManager>
        <asp:LinkButton ID="lnkSearch" style="display:none" runat="server" onclick="lnkSearch_Click"></asp:LinkButton>
        <%-- 协作ID --%>
        <input type="hidden" id="hdId" runat="server" />
        <%-- 查询方式 basic：基本查询 advanced：高级查询 --%>
        <input type="hidden" id="hdSearchType" runat="server" />
        <table border="0" cellpadding="0" cellspacing="0" align="center" width="98%" class="tbToolbar">
            <tr>
                <td align="left">
                    <div class="tbSeparator"></div>
                </td>
                <td align="left" class="titlebar" style="width:100%">
                    <nobr>
                        协作空间-协作管理
                    </nobr>
                </td>
                <td align="right">
                    <div class="tbSeparatorEnd"></div>
                </td>
            </tr>
        </table>
        <table border="0" cellpadding="0" runat="server" cellspacing="0" align="center" style="width:98%" class="tableborder">
            <tr id="trBasic" runat="server">
                <td align="left" style="width:20%" class="pformright">
                    <nobr>
                        <select id="selCollaborate" runat="server" style="width:100%" onchange="doChangeType()" class="inputselect">
                            <option value="1">协作标题</option>
                            <option value="2">协作类型</option>
                            <option value="3">发布人</option>
                            <option value="4">协作状态</option>                            
                        </select>
                    </nobr>
                </td>
                <td style="width:20%" class="pformright">
                    <input type="text" id="txtCollaborativeTitle1" runat="server" class="input" style="width:99.4%" />
                    <select id="selCollaborativeType1" runat="server" class="inputselect" style="width:99.4%;display:none"></select>
                    <input type="text" id="txtPublisher1" runat="server" class="input" style="width:99.4%;display:none" />
                    <select id="selCollaborativeStatus" runat="server" class="inputselect" style="width:99.4%;display:none">
                        <option value="">全部</option>
                        <option value="0">未生效</option>
                        <option value="1">已生效</option>
                        <option value="2">已终止</option>
                    </select>
                </td>
                <td class="pformright" align="left">
                    <nobr>
                        <a href="javascript:doSearch()" class="linktext"><img style="cursor:pointer" src="../images/search.gif" alt="查询" />查询</a>
                    </nobr>
                </td>
                <td align="left" style="width:70%" class="pformright">
                    <nobr>
                        <input type="button" runat="server" value="高级搜索" class="button" id="btnAdvanceSearch" onclick="doAdvanceSearch()" />
                    </nobr>
                </td>
            </tr>
            <tr id="trAdvanced" runat="server" style="display:none">
                <td style="width:99.4%" colspan="4">
                    <table id="tbAdvanced" border="0" cellpadding="0" cellspacing="0" align="center" style="width:100%;background-color:#F5F5F4">
                        <tr>
                            <td colspan="6" align="left" class="pformright" style="background-color:#F5F5F4">
                                &nbsp;高级搜索条件
                                <img id="Img1" src="../images/modmenu_up.gif" alt="隐藏" runat="server" style="cursor:pointer" onclick="javascript:doHiddeAdvance()" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" style="width:15%" class="pformleft">
                                协作类型
                            </td>
                            <td align="left" style="width:20%" class="pformrightline">
                                <select id="selCollaborativeType" runat="server" class="inputselect" style="width:99%"></select>
                            </td>
                            <td align="right" style="width:15%" class="pformleft">
                                协作标题
                            </td>
                            <td align="left" style="width:20%" class="pformrightline">
                                <input type="text" id="txtCollaborativeTitle" runat="server" class="input" style="width:99%" />
                            </td>
                            <td align="right" style="width:10%" class="pformleft">
                                状态
                            </td>
                            <td class="pformright" style="width:20%">
                                <select id="selStatus" runat="server" class="inputselect" style="width:99%">
                                    <option value="">全部</option>
                                    <option value="0">未生效</option>
                                    <option value="1">已生效</option>
                                    <option value="2">已终止</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" style="width:15%" class="pformleft">
                                发布人
                            </td>
                            <td align="left" style="width:20%" class="pformrightline">
                                <input type="text" id="txtPublisher" runat="server" class="input" style="width:99%" />
                            </td>
                            <td align="right" style="width:15%" class="pformleft">
                                发布日期
                            </td>
                            <td align="left" colspan="2" class="pformright">
                                <nobr>
                                    <input type="text" id="txtBeginDate" runat="server" class="input" />
                                    <img src="../images/toolbar/Calendar.gif" class="getdate" alt="开始时间" relaobj="txtBeginDate" />
                                    到
                                    <input type="text" id="txtEndDate" runat="server" class="input" />
                                    <img src="../images/toolbar/Calendar.gif" class="getdate" alt="结束时间" relaobj="txtEndDate" />
                                </nobr>
                            </td>
                            <td class="pformright" align="right">
                                <a href="javascript:doSearch()" class="linktext"><img style="cursor:pointer" src="../images/search.gif" alt="查询" />查询</a>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td style="width:99.4%" colspan="4">
                    <table border="0" width="100%">
                        <tr>
                            <td style="width:99.4%;background-color:#F5F5F4">
                                &nbsp;图例：
                                <img src="../images/toolbar/start.gif" alt="" />启动协作
                                <img src="../images/toolbar/stop.gif" alt="" />终止协作
                                <img src="../images/toolbar/restart.gif" alt="" />重新发布
                            </td>
                            <td style="background-color:#F5F5F4">
                                <nobr>
                                    <a id="A1" href="javascript:doEdit('')" class="linktext" runat="server">
                                        <img alt="新增" src="../images/toolbar/new.gif" />新增
                                    </a>
                                    <a id="A2" href="javascript:doDelete('')" class="linktext" runat="server">
                                        <img alt="删除" src="../images/toolbar/delete.gif" />删除
                                    </a>
                                    &nbsp;
                                </nobr>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <dxwgv:ASPxGridView ID="gvCollaborationList" runat="server" Width="98%" 
            KeyFieldName="Id" align="center" 
            onhtmlrowcreated="gvCollaborationList_HtmlRowCreated">
            <SettingsPager AlwaysShowPager="True" PageSize="15">
                <FirstPageButton Visible="True">
                </FirstPageButton>
                <LastPageButton Visible="True">
                </LastPageButton>
            </SettingsPager>
            <Styles>
                <Row CssClass=""></Row>
                <AlternatingRow  CssClass="" Enabled="true"/>
                <SelectedRow  CssClass=""></SelectedRow>                
            </Styles>
            <Settings ShowFilterRow="false" ShowPreview="True"/>
            <SettingsBehavior ColumnResizeMode="Control" />
            <SettingsCustomizationWindow Enabled="true" />
            <Columns>
                <dxwgv:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0" Width="3%">
                    <HeaderTemplate>
                        <input id="Checkbox1" type="checkbox" runat="server" onclick="gvCollaborationList.SelectAllRowsOnPage(this.checked);" style="vertical-align:middle;" title="Select/Unselect all rows on the page"></input>
                    </HeaderTemplate>
                    <HeaderStyle Paddings-PaddingTop="1" Paddings-PaddingBottom="1" HorizontalAlign="Center">
                        <Paddings PaddingTop="1px" PaddingBottom="1px"></Paddings>
                     </HeaderStyle>
                </dxwgv:GridViewCommandColumn>
                <dxwgv:GridViewDataTextColumn Caption="协作标题" Width="30%" VisibleIndex="1" FieldName="Title">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="协作类型" Width="8%" VisibleIndex="2" FieldName="TypeId">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center" Wrap="False"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="发布人" Width="8%" VisibleIndex="3" FieldName="PublisherName">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="发布日期" Width="17%" VisibleIndex="4" FieldName="PublishDate">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center" Wrap="False"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="终止日期" Width="17%" VisibleIndex="5" FieldName="FinishDate">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center" Wrap="False"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="状态" Width="7%" VisibleIndex="6" FieldName="Status">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center" Wrap="False"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="发布人ID" Width="8%" VisibleIndex="8" Visible="false" FieldName="PublisherId">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="操作" VisibleIndex="7" Width="10%">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center" Wrap="False"></CellStyle>
                    <DataItemTemplate>
                        <a id="haEdit" runat="server">编辑</a>&nbsp;&nbsp;
                        <a id="haOperate" runat="server"><img alt="" src="" id="imgOperate" runat="server" /></a>
                    </DataItemTemplate>
                </dxwgv:GridViewDataTextColumn>
            </Columns>
            <ClientSideEvents SelectionChanged="function(s,e){OnGridSelectionChanged();}"/>
        </dxwgv:ASPxGridView>
    </ccit:ActionForm>
    <script language="javascript" type="text/javascript">
        <!--
        function OnGridSelectionChanged(){           
            gvCollaborationList.GetSelectedFieldValues("Id",OnGridSelectionComplete);
        }
        
        function OnGridSelectionComplete(values){
            document.getElementById("hdId").value = values;
        }
        //-->
    </script>
</body>
</html>
